import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/index')
      }
    ]
  },
  {
    path: '/wh-map',
    component: Layout,
    children: [
      {
        path: '/wh-map',
        component: () => import('@/views/whMap/index')
      }
    ]
  },
  {
    path: '/wh-form',
    component: () => import('@/views/whForm/index')
    // component: Layout,
    // children: [
    //   {
    //     path: '/wh-form',
    //     component: () => import('@/views/whForm/index')
    //   }
    // ]
  },
  {
    path: '/wh-flow',
    component: Layout,
    children: [
      {
        path: '/wh-flow-index',
        component: () => import('@/views/whFlow/index')
      },
      {
        path: '/wh-flow-display',
        component: () => import('@/views/whFlow/display')
      },
      {
        path: '/wh-flow-list',
        component: () => import('@/views/whFlow/list')
      }
    ]
  },
  {
    path: '/graph-editor',
    component: () => import('@/views/whGraphEditor/index')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
